<template>
    <view class="order-list-item touch" @click="goDetail">
        <view class="order-header">
            <view class="title">{{ item.StoreName }}</view>
            <view class="state"><text class="dot" :class="getStateName()"></text><text>{{ item.StateName }}</text>
            </view>
        </view>
        <view class="order-sn">
            <view class="tags">
                <image src="/static/img/dai.png" v-if="item.ValetType == 1"></image>
                <image src="/static/img/ding.png" v-else></image>
                <text class="number-text">{{ item.Sn }}</text>
            </view>
            <text class="time">{{ item.AddTime }}</text>
        </view>
        <view class="order-bottom">
            <view>
                <text class="item-label">数量：</text>
                <text class="price-value">{{ item.ProductCount }}</text>
            </view>
            <view class="price">
                <text class="item-label">金额：</text>
                <text class="price-value">￥{{ item.ProductPrice }}</text>
                <text class="pay-state" :class="getPayStatus()">{{
                    item.PayStatusName ? `${item.PayStatusName}` : ""
                }}</text>
            </view>
        </view>
    </view>
</template>

<script>
import easyTag from "@/components/easy/easy-tag.vue"
export default {
    components: {
        easyTag,
    },
    props: {
        item: {
            type: Object,
            default: () => { },
        },
    },
    data() {
        return {}
    },
    methods: {
        goDetail() {
            this.easyGoTo("/pages/order/detail?orderId=" + this.item.OrderId)
        },
        getTypeText() {
            let text = ""
            switch (this.item.ValetType) {
                case 1:
                    text = "代"
                    break
                default:
                    text = "订"
                    break
            }
            return text
        },
        getStateName() {
            let text = ""
            switch (this.item.StateName) {
                case "待发货":
                    text = "docred"
                    break
                case "待订单审核":
                    text = "docyellow"
                    break
                case "待确认收款":
                    text = "docyellow"
                    break
                case "已完成":
                    text = "docgreen"
                    break
                default:
                    text = "dot"
                    break
            }
            return text
        },
        getPayStatus() {
            let text = ""
            switch (this.item.PayStatusName) {
                case "部分付款":
                    text = "pay-state1"
                    break
                case "已付款":
                    text = "pay-state2"
                    break
                default:
                    text = ""
                    break
            }
            return text
        },
        getStateText() {
            let text = ""
            switch (this.item.Type) {
                case 4:
                    text = "待订单审核"
                    break
                default:
                    text = "订"
                    break
            }
            return text
        },
    },
}
</script>

<style lang="scss">
.order-list-item {
    display: flex;
    flex-direction: column;
    padding: 20rpx $app-page-padding;
    background: $color-white;
    margin: 0 $app-page-padding $app-page-padding;
    border-radius: 12rpx;

    .order-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20rpx;

        .title {
            font-size: $font-size-28;
            color: $color-gray-1;
            font-weight: bold;
        }

        .state {
            height: 44rpx;
            background: #f3f3f4;
            border-radius: 22rpx;
            padding: 0 16rpx;
            display: flex;
            justify-content: center;
            align-items: center;

            text {
                font-size: 24rpx;
                color: $color-gray-2;
            }

            .dot {
                width: 8rpx;
                height: 8rpx;
                background: #b2b2b2;
                border-radius: 50%;
                margin-right: 10rpx;
            }

            .docred {
                background: #e52d4d;
            }

            .docyellow {
                background: #ffbd00;
            }

            .docgreen {
                background: #12be73;
            }
        }
    }

    .order-sn {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 20rpx;
        border-bottom: 1rpx solid #ebebeb;

        .tags {
            display: flex;

            image {
                width: 40rpx;
                height: 40rpx;
                margin-right: 12rpx;
            }
        }
    }

    .order-bottom {
        padding: 20rpx 0 4rpx 0;
    }

    .price {
        display: flex;
        flex-direction: row;
        align-items: center;
        margin-top: 10rpx;

        .pay-state {
            margin-left: 10rpx;
            height: 34rpx;
            padding: 0 8rpx;
            background: #fbe8eb;
            border-radius: 0px 12rpx 12rpx 12rpx;
            font-size: 24rpx;
            color: #e52d4d;
        }

        .pay-state1 {
            background: #fef7e4;
            color: #ffbd00;
        }

        .pay-state2 {
            background: #e6f7f0;
            color: #12be73;
        }

        .time {
            flex: 1;
            display: flex;
            justify-content: flex-end;
        }
    }
}

.un-pay {
    color: $color-orange-1;
}

.number-text {
    color: $color-gray-3;
}

.time {
    color: $app-color-text-tip;
}

.item-label {
    color: #333333;
    font-size: 28rpx;
}

.price-value {
    font-weight: 700;
    font-size: 32rpx;
    color: #333333;
}

.order-state {
    color: $color-orange-1;
}
</style>
